package controller.cartp;

import com.alibaba.fastjson.JSON;
import com.zuche.framework.tradingPlatform.CurrenceSource;
import com.zuche.framework.tradingPlatform.ReplyRequestParams;
import com.zuche.framework.tradingPlatform.RequestParams;
import com.zuche.framework.utils.PropertiesReader;
import controller.constant.CarTpConstant;
import controller.enums.GroupTypeEnum;
import controller.remote.CartpRemoteClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by 雷霆 on 2016/10/25.
 */
@Controller
@RequestMapping(value = "alipay/",produces = "text/html;charset=utf-8")
public class AliPayController {
    private static final Logger logger = LoggerFactory.getLogger(UnionPayRPCTestController.class);

    /**
     * 网页支付 web
     * @return
     */
    @RequestMapping(value = "doWebPay.do_")
    public static  Object doWebPay(HttpServletRequest request,
                                   HttpServletResponse response){
        Map<String,String> requestMap=new HashMap<String, String>();
        requestMap.put(RequestParams.ASYNC_REPLY_URL,"www.baidu.com");
        requestMap.put(ReplyRequestParams.NOTIFY_URL,"www.baidu.com");

        requestMap.put(RequestParams.REDO, String.valueOf(false));
        requestMap.put(RequestParams.SYS_GROUP,"5");
        requestMap.put(RequestParams.BUSINESS_ID,"" + System.currentTimeMillis());
        requestMap.put(RequestParams.BUSINESS_MONEY,"1");
        requestMap.put(RequestParams.BUSINESS_NAME,"test");
//        paramMap.put(RequestParams.GROUP_TYPE, GroupType.ALI_SDK);
        requestMap.put(RequestParams.GROUP_TYPE, GroupType.WEB_BANK);
        requestMap.put(RequestParams.SOURCE_ID, CurrenceSource.ALIPAY_M);
        requestMap.put(RequestParams.PAYER_ID,"5125392");
        requestMap.put(RequestParams.PAYER_TEL,"15810074478");

        logger.error(" [carttp调用参数] : " + JSON.toJSONString(requestMap));
        CartpRemoteClient.doMvc(request, response, requestMap, true);
        // logger.error(" [carttp返回结果] : " + JSON.toJSONString(resultMap));

        return null;
    }
}
